//------------Sonic CD Rise Platform Script-------------//
//--------Scripted by Christian Whitehead 'The Taxman'--------//
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//

//-------Aliases-------//
#alias 47: TYPE_RISEPLATFORM


sub ObjectMain
	switch Object.State
	case 0
		Object.Value2=0
		if Object.Value0==1
			Object.State=1
			Object.Priority=1
			Object.Value3=-262144
			Object.Value5=0
		endif
		break
	case 1
		Object.Value2=Object.Value3
		if Object.Value5<8
			Object.Value5++
		else
			Object.Value5=0
			Object.State=2
		endif
		if Object.OutOfBounds==1
			Object.YPos=Object.Value4
			Object.State=0
			Object.Value1=0
		endif
		break
	case 2
		if Object.Value3<0
			Object.Value3+=8192
		else
			Object.State=3
		endif
		Object.Value2=Object.Value3
		if Object.OutOfBounds==1
			Object.YPos=Object.Value4
			Object.State=0
			Object.Value1=0
		endif
		break
	case 3
		if Object.Value0==1
			if Object.Value1<16
				Object.Value1++
				TempValue0=Object.Value1
				TempValue0&=3
				if TempValue0==3
					Object.Value2=65536
				else
					Object.Value2=0
				endif
			else
				Object.Value2=0
			endif
		else
			if Object.Value1>0
				Object.Value1--
				TempValue0=Object.Value1
				TempValue0&=3
				if TempValue0==3
					Object.Value2=-65536
				else
					Object.Value2=0
				endif
			else
				Object.Value2=0
			endif
		endif
		if Object.OutOfBounds==1
			Object.YPos=Object.Value4
			Object.State=0
			Object.Value1=0
		endif
		break

	endswitch
	Object.Value0=0
endsub


sub ObjectPlayerInteraction
	PlayerObjectCollision(C_PLATFORM,-32,-9,32,12)
	if CheckResult==1
		Object.Value0=1
		Player.YPos+=Object.Value2
	endif
endsub


sub ObjectDraw
	Object.YPos+=Object.Value2
	DrawSprite(0)
endsub


sub ObjectStartup
	LoadSpriteSheet("R1/Objects.gif")
	SpriteFrame(-32,-16,64,32,101,109)
	ArrayPos0=32
	while ArrayPos0<1056
		if Object[ArrayPos0].Type==TypeName[RisePlatform]
			Object[ArrayPos0].Value4=Object[ArrayPos0].YPos
		endif
		ArrayPos0++
	loop
endsub

sub RSDK
	LoadSpriteSheet("Global/Display.gif")
	SetEditorIcon(Icon0,SingleIcon,-16,-16,32,32,1,143)
endsub
